#ifndef CUCOMPLEX_HPP
#define CUCOMPLEX_HPP

template<class T>
class cuComplex {
public:
	__device__
	cuComplex(T _re=T(0), T _im=T(0)) : re(_re), im(_im) {}
	
	__device__
	cuComplex<T> operator+(const cuComplex<T> &rhs) const {
		return cuComplex(re + rhs.re, im + rhs.im);
	}
	__device__
	cuComplex<T> operator-(const cuComplex<T> &rhs) const {
		return cuComplex(re - rhs.re, im - rhs.im);
	}
	__device__
	cuComplex<T> operator*(const cuComplex<T> &rhs) const {
		return cuComplex(re*rhs.re - im*rhs.im, im*rhs.re + re*rhs.im);
	}
	__device__
	cuComplex<T> operator/(T k) { return cuComplex<T>(re/k, im/k); }
	
	__device__
	T real() const {
		return re;
	}
	
private:
	T re, im;
};

#endif // CUCOMPLEX_H
